import request from '../utils/request'

// 获取商品列表
export const GoodsList = (page = 1, obj = {}, token) => {


    console.log("33333333");
    let info = {
        page_no: page,
        page_size: 8
    }
    if (obj.keyword) {
        info.keyword = obj.keyword
    }
    if (obj.thickness) {
        info.thickness = obj.thickness
    }
    if (obj.spec) {
        let str = obj.spec.join()
        if (str != '') {
            info.spec_id = str
        }

    }
    if (obj.technology) {
        let str = obj.technology.join()
        if (str != '') {
            info.technology_id = str
        }
    }
    if (obj.category) {
        let str = obj.category.join()
        if (str != '') {
            info.classification_id = str
        }

    }
    if (obj.brand_id) {
        let str = obj.brand_id.join()
        if (str != '') {
            info.brand_id = str
        }
    }
    if (obj.type) {
        let str = obj.type.join()
        if (str != '') {
            info.type_id = str
        }
    }
    if (obj.typea) {
        let str = obj.typea
        if (str != '') {
            info.typea_id = str.join()
        }
    }
    if (obj.typeb) {
        let str = obj.typeb
        if (str != '') {
            info.typeb_id = str.join()
        }
    }
    if (obj.typec) {
        let str = obj.typec
        if (str != '') {
            info.typec_id = str.join()
        }
    }
    if (obj.typed) {
        let str = obj.typed
        if (str != '') {
            info.typed_id = str.join()
        }
    }
    if (obj.typee) {
        let str = obj.typee
        if (str != '') {
            info.typee_id = str.join()
        }
    }

    return request.get('goods/lists', {
        params: info,
        headers: {
            token
        }
    })
}

// 获取商品详情
export const GoodsDetail = (id, token) => {
    return request.get(`goods/detail/?id=${id}`, {
        headers: {
            token
        }
    })
}

// 修改商品数量

export const CartUpdate = (id, num, token) => {
    return request.post('cart/change', {
        cart_id: id,
        goods_num: num
    }, {
        headers: {
            token
        }
    })
}

// 删除商品数量

export const CartDel = (id, token) => {
    return request.post('cart/del', {
        cart_id: id,
    }, {
        headers: {
            token
        }
    })
}

// 商品全选

export const CartAll = (type, selected, all=0,token) => {
    return request.post('cart/selected', {
        type,
        selected,
        all,
        cart_id:0
    }, {
        headers: {
            token
        }
    })
}

export const CartSel = (type, selected, cart_id, all=1,token) => {
    return request.post('cart/selected', {
        type,
        selected,
        cart_id,all
    }, {
        headers: {
            token
        }
    })
}


// 提交订单
export const CartSubmit = (data, token) => {
    return request.post('order/add', data, {
        headers: {
            token
        }
    })
}

export const CartInfo = (token) => {
    return request.post('order/lists', {}, {
        headers: {
            token
        }
    })
}
export const Cartlist = (page, token) => {
    return request.get('order/lists', {
        params: {
            page_no: page,
            page_size: 3
        },
        headers: {
            token
        }
    })
}


// 筛选

// 规格尺寸

export const GoodsSpec = (token) => {
    return request.get('access/spec', {
        headers: {
            token
        }
    })
}
// 厂家品牌
export const GoodsBrand = (token) => {
    return request.get('access/brand', {
        headers: {
            token
        }
    })
}
// 工艺
export const GoodsTechnology = (token) => {
    return request.get('access/technology', {
        headers: {
            token
        }
    })
}


// 配套
export const GoodsPei = (token) => {
    return request.get('access/typea', {
        headers: {
            token
        }
    })
}

// 颜色
export const GoodsColor = (token) => {
    return request.get('access/typeb', {
        headers: {
            token
        }
    })
}
// 适用
export const GoodsSy = (token) => {
    return request.get('access/typec', {
        headers: {
            token
        }
    })
}

// 品类
export const GoodsPin = (token) => {
    return request.get('access/typed', {
        headers: {
            token
        }
    })
}

// 色类
export const GoodsSe = (token) => {
    return request.get('access/typee', {
        headers: {
            token
        }
    })
}

// 产品类别
export const GoodsCategory = (token) => {
    return request.get('access/classification', {
        headers: {
            token
        }
    })
}

export const getthickness = (token) => {
    return request.get('access/thickness', {
        headers: {
            token
        }
    })
}


// 轮播
export const BannerGet = () => {
    return request.get('zgyb.config/slide')
}

// 导出
export const CartExp = (type, token) => {
    return request.get('cart/export', {
        headers: {
            token
        },
        params: {
            type: type
        },
    })
}

// 直通
export const goodstype = (token) => {
    return request.get('access/type', {
        headers: {
            token
        }
    })
}


// 获取权限
export const getAuth = (token) => {
    return request.get('access/lists', {
        headers: {
            token
        }
    })
}

export function orderlists(data, token) {
    return request.get('/order/lists', {
        params: data,
        headers: {
            token
        }
    })
}

export function orderpay(data, token) {
    return request.post('/order/pay', 
        data,{
        headers: {
            token
        }
    })
}

export function getCancelOrder(data, token) {
    return request.post('/order/cancel', 
        data,{
        headers: {
            token
        }
    })
}

 // 上传提货单
 export function orderupload(data,token){
    return request.post('/order/upload', data,{
        headers: {
            token
        }
    })
} 